package edu.ccut.saturn.authority.core.common;

import java.util.ArrayList;
import java.util.List;

import edu.ccut.saturn.component.DefaultComponent;
import edu.ccut.saturn.component.IParameterContext;
import edu.ccut.saturn.component.SaturnData;

public class ExtractAttributeList extends DefaultComponent {
	@SuppressWarnings("unchecked")
	@Override
	public void execute(IParameterContext parameterContext) throws Exception {
		List<SaturnData> list = (List<SaturnData>)parameterContext.getParameterValue(0);
		
		String key = (String)parameterContext.getParameterValue(1);
				
		//List<String> listResult = new ArrayList<String>();
		List<Object> listResult = new  ArrayList<Object>();
		if(list == null){			
		}else{
			for(int i = 0; i < list.size(); i++){
				SaturnData data = list.get(i);
				listResult.add(data.get(key));
			}
		}
		parameterContext.setParameter(2, listResult);
	}
}